package com.zyk.leetcode;

/**
 * @author zhangsan
 * @date 2021/4/22 10:42
 */
public class C122 {

    // 贪心, 只要今天比昨天高就交易
    public int maxProfit(int[] prices) {
        int ans = 0;
        for (int i = 1; i < prices.length; i++)
            ans += Math.max(prices[i] - prices[i - 1], 0);
        return ans;
    }

}
